<template>
  <Form :form="form">
    <SchemaField :schema="schema"/>
    <Submit @submit="onSubmit">提交</Submit>
  </Form>
</template>

<script lang="ts">
import { createForm } from '@formily/core'
import { createSchemaField } from '@formily/vue'
import { Form, FormItem, Submit, TimePicker } from '@formily/vxe-table/src'

const schema = {
  type: 'object',
  properties: {
    time: {
      type: 'string',
      title: '时间',
      'x-decorator': 'FormItem',
      'x-component': 'TimePicker',
      'x-component-props': {
        style: {
          width: '240px',
        },
      },
    },
    'time-range': {
      'type': 'void',
      "title": "时间范围",
      "x-decorator": 'FormItem',
      "x-component": "Space",
      properties: {
        startTime: {
          type: 'string',
          'x-component': 'TimePicker',
          'x-component-props': {
            style: {
              width: '240px',
            },
          },
        },
        endTime: {
          type: 'string',
          'x-component': 'TimePicker',
          'x-component-props': {
            style: {
              width: '240px',
            },
          },
        }
      }
    }
  },
}

const form = createForm()
const {SchemaField} = createSchemaField({
  components: {
    FormItem,
    TimePicker,
  },
})

export default {
  components: {Form, SchemaField, Submit},
  data() {
    return {
      form,
      schema,
    }
  },
  methods: {
    onSubmit(value) {
      console.log(value)
    },
  },
}
</script>
